<!-- history_books.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>历史书籍</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 800px;
            margin: 20px auto;
            padding: 0 20px;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        ul {
            list-style-type: none;
            padding: 0;
        }
        li {
            background-color: #fff;
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        li:hover {
            background-color: #f0f0f0;
        }
        a {
            color: #007bff;
            text-decoration: none;
            margin-left: 10px;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>历史书籍</h1>
    <ul id="history-books">
        <li>中国史 - ￥20 <a href="#" onclick="addToCart('中国史', 20)">购买</a></li>
        <li>世界史 - ￥25 <a href="#" onclick="addToCart('世界史', 25)">购买</a></li>
        <li>近现代史 - ￥30 <a href="#" onclick="addToCart('近现代史', 30)">购买</a></li>
    </ul>
    <a href="view_cart.html">查看购物车</a>
</div>
<script>
        function addToCart(name, price) {
            var cart = JSON.parse(localStorage.getItem('cart')) || [];
            cart.push({ name: name, price: price });
            localStorage.setItem('cart', JSON.stringify(cart));
        }
    </script>
</body>
</html>
